home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 December / PCWDEC06.iso / Software / Freeware / Partition Logic 0.63 / partlogic-0.63.iso / system / headers / sys / memory.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-08-22  |  2.4 KB  |  90 lines

  1. // 
  2. //  Visopsys
  3. //  Copyright (C) 1998-2006 J. Andrew McLaughlin
  4. //  
  5. //  This library is free software; you can redistribute it and/or modify it
  6. //  under the terms of the GNU Lesser General Public License as published by
  7. //  the Free Software Foundation; either version 2.1 of the License, or (at
  8. //  your option) any later version.
  9. //
  10. //  This library is distributed in the hope that it will be useful, but
  11. //  WITHOUT ANY WARRANTY; without even the implied warranty of
  12. //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
  13. //  General Public License for more details.
  14. //
  15. //  You should have received a copy of the GNU Lesser General Public License
  16. //  along with this library; if not, write to the Free Software Foundation,
  17. //  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. //
  19. //  memory.h
  20. //
  21.  
  22. // This file contains definitions and structures for using and manipulating
  23. // memory in Visopsys.
  24.  
  25. #if !defined(_MEMORY_H)
  26.  
  27. #include <sys/lock.h>
  28. #include <sys/errors.h>
  29.  
  30. // Definitions
  31. #define MEMORY_PAGE_SIZE             4096
  32. #define MEMORY_BLOCK_SIZE            MEMORY_PAGE_SIZE
  33. #define MEMORY_MAX_DESC_LENGTH       32
  34.  
  35. #define USER_MEMORY_HEAP_MULTIPLE    (64 * 1024)    // 64 Kb
  36. #define KERNEL_MEMORY_HEAP_MULTIPLE  (1024 * 1024)  // 1 meg
  37.  
  38. typedef struct {
  39.   int used;
  40.   int process;
  41.   void *start;
  42.   void *end;
  43.   void *previous;
  44.   void *next;
  45.   const char *function;
  46.  
  47. } mallocBlock;
  48.  
  49. // Struct that describes one memory block
  50. typedef struct {
  51.   int processId;
  52.   char description[MEMORY_MAX_DESC_LENGTH];
  53.   unsigned startLocation;
  54.   unsigned endLocation;
  55.  
  56. } memoryBlock;
  57.  
  58. // Struct that describes overall memory statistics
  59. typedef struct {
  60.   unsigned totalBlocks;
  61.   unsigned usedBlocks;
  62.   unsigned totalMemory;
  63.   unsigned usedMemory;
  64.  
  65. } memoryStats;
  66.  
  67. typedef struct {
  68.   int (*multitaskerGetCurrentProcessId) (void);
  69.   void * (*memoryGetSystem) (unsigned, const char *);
  70.   int (*lockGet) (lock *);
  71.   int (*lockRelease) (lock *);
  72.   void (*error) (const char *, const char *, int, kernelErrorKind, 
  73.          const char *, ...);
  74.  
  75. } mallocKernelOps;
  76.  
  77. // For using malloc() in kernel space
  78. extern unsigned mallocHeapMultiple;
  79. extern mallocKernelOps mallocKernOps;
  80.  
  81. // Extras for malloc debugging
  82. void *_doMalloc(unsigned, const char *);
  83. void _doFree(void *, const char *);
  84. int _mallocBlockInfo(void *, memoryBlock *);
  85. int _mallocGetStats(memoryStats *);
  86. int _mallocGetBlocks(memoryBlock *, int);
  87.  
  88. #define _MEMORY_H
  89. #endif
  90.